package KK.Data.Scale
{
	import flash.geom.Point;
	import flash.geom.Rectangle;

	public class Scale16 implements IScale
	{
		private var sourceData:Rectangle;
		
		private var _lastRectangle:Rectangle;
		public function Scale16(x:int,y:int,width:int,height:int):void
		{
			_lastRectangle=new Rectangle;
			sourceData=new Rectangle(x,y,(width)/4,(height)/4);
		}
		
		/**
		 * 获取像素点的坐标 
		 * @param point
		 * @return 
		 * 
		 */
		public function getPixelPoint(point:Point):Point
		{
			// TODO Auto Generated method stub
			var result:Point=new Point(); 
			result.x=Math.ceil(point.x/sourceData.width);
			result.y=Math.ceil(point.y/sourceData.height);
			
			return result;
		}
		
		/**
		 * 获取坐标的像素位置 
		 * @param point
		 * @return 
		 * 
		 */
		public function getPointPixel(point:Point):Point
		{
			// TODO Auto Generated method stub
			var result:Point=new Point();
			
			result.x=point.x*sourceData.width;
			result.y=point.y*sourceData.height;
			return result;
		}
		
		/**
		 * 
		 * @param point
		 * 
		 */
		public function getPointRectangle(point:Point):Rectangle{
			var result:Rectangle=_lastRectangle;
			
			var point:Point=getPointPixel(getPixelPoint(point));
			result.x=point.x;
			result.y=point.y;
			result.width=sourceData.width;
			result.height=sourceData.height;
			return result;
		}
		
		
		
		
		
	}
}